insert into rafikidb.dbo.entity
select 'TranscriptItem' as entitytype, 'TranscriptItemMaster' as entitysubtype, null as entityname, cast(transcriptid as varchar(30)) as friendlyid 
from Transcripts

insert into rafikidb.dbo.Attributes(AttributeValueString,AttributeID,EntityID)
select CourseName as attributevaluestring,1014 as attributeid,entity.entityid
from Transcripts inner join rafikidb.dbo.Entity on cast(transcriptid as varchar(30)) = entity.FriendlyID
Where entitytype = 'TrnascriptItem' and EntitySubType = 'TranscriptItemMaster'

insert into rafikidb.dbo.Attributes(AttributeValueString,AttributeID,EntityID)
select SchoolYear as attributevaluestring,1015 as attributeid,entity.entityid
from Transcripts inner join rafikidb.dbo.Entity on cast(transcriptid as varchar(30)) = entity.FriendlyID
Where entitytype = 'TrnascriptItem' and EntitySubType = 'TranscriptItemMaster'

insert into rafikidb.dbo.Attributes(AttributeValueString,AttributeID,EntityID)
select YearGrade as attributevaluestring,1017 as attributeid,entity.entityid
from Transcripts inner join rafikidb.dbo.Entity on cast(transcriptid as varchar(30)) = entity.FriendlyID WHERE YearGrade != 'NULL'
Where entitytype = 'TrnascriptItem' and EntitySubType = 'TranscriptItemMaster'

insert into rafikidb.dbo.Attributes(AttributeValueString,AttributeID,EntityID)
select GPA as attributevaluestring,1016 as attributeid,entity.entityid
from Transcripts inner join rafikidb.dbo.Entity on cast(transcriptid as varchar(30)) = entity.FriendlyID
Where entitytype = 'TrnascriptItem' and EntitySubType = 'TranscriptItemMaster'